package com.jerry.base.java8.lambda;

import java.util.stream.Stream;

/**
 * 类名::非静态方法的方法引用
 *
 * @author Jerry
 * @since 2024/7/24 20:12
 */
public class MethodRef2 {

    public static void main(String[] args) {
        Stream.of(
                        new Student("张无忌", "男"),
                        new Student("周芷若", "女"),
                        new Student("宋青书", "男")
                ).filter(Student::isMale)
                .forEach(Student::print);
    }

    record Student(String name, String sex) {

        boolean isMale() {
            return sex.equals("男");
        }

        void print() {
            System.out.println(this);
        }
    }

}